import request from '../../utils/request';
import Constants from '../../utils/Constants';


/**
 * 新增供应商
 *
 */
export async function addSupplier(data) {
    return request(apiPath.imagent + "/api/supplier", {
        method: 'post',
        data
    });
}


/**
 * 修改供应商
 *
 */
export async function updateSupplier(data) {
    return request(apiPath.imagent + "/api/supplier", {
        method: 'put',
        data
    });
}

/**
 * 删除供应商
 *
 */
export async function deleteById({id}) {
    return request(apiPath.imagent + "/api/supplier/" + id, {
        method: 'delete'
    });
}

/**
 *根据id获取供应商
 *
 */
export async function getById({id}) {
    return request(apiPath.imagent + "/api/supplier/" + id, {
        method: 'get'
    });
}


/**
 * 分页获取供应商列表
 *
 */
export async function getListForPage({supplier, supplierType, transportType, page}) {
    return request(apiPath.imagent + "/api/supplier", {
        method: 'get',
        data: {supplier, supplierType, transportType, page: page.page, size: page.size }
    });
}


/** 新增收款人
*
*/
export async function addSupplierPayee(data) {
    return request(apiPath.imagent + "/api/logistics/supplier/payee", {
        method: 'post',
        data
    });
}


/**
 * 删除收款人
 *
 */
export async function deleteSupplierPayeeById({id}) {
    return request(apiPath.imagent + "/api/logistics/supplier/payee/" + id, {
        method: 'delete'
    });
}


/**
 *根据id获取收款人信息
 *
 */
export async function getSupplierPayeeById({id}) {
    return request(apiPath.imagent + "/api/logistics/supplier/payee/" + id, {
        method: 'get'
    });
}


/**
 * 分页获取收款人列表
 *
 */
export async function getPayeeListForPage({supplierid, page}) {
    return request(apiPath.imagent + "/api/logistics/"+ supplierid +"/payee", {
        method: 'get',
        data: {supplierid, page: page.page, size: page.size }
    });
}


/**
 *
 * 查询供应商List
 */
export async function getSupplierList(data){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data
    });
}

/**
 *
 * 查询拖车供应商List
 */
export async function getTraSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.TRAILER }
    });
}

/**
 *
 * 查询报关供应商List
 */
export async function getDecSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.DECLARE }
    });
}

/**
 *
 * 查询空运供应商List
 */
export async function getAirSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.AIR }
    });
}

/**
 *
 * 查询快递供应商List
 */
export async function getExpSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.EXPRESS }
    });
}

/**
 *
 * 查询保险供应商List
 */
export async function getInsSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.INSURANCE }
    });
}

/**
 *
 * 查询仓库供应商List
 */
export async function getStoSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.DEPOT }
    });
}

/**
 *
 * 查询商检供应商List
 */
export async function getInspectionSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.INSPECTION }
    });
}

/**
 *
 * 查询产地证供应商List
 */
export async function getCoSupplierList({ supplierType }){
    return request(apiPath.imagent + "/api/supplier/all",{
        method:'get',
        data: { supplierType: Constants.SUPPLIER_TYPE.CO }
    });
}